package Porperties;

import javax.swing.text.html.HTMLDocument;
import java.util.*;

public class porperties {
    public static void main(String[] args) {
        //创建一个集合
        Properties pro =new Properties();
        pro.setProperty("u1","jabasdawdaf");
        pro.setProperty("u2","awfdshj");
        //通过key获取value
        String u1=pro.getProperty("u1");
        String u2=pro.getProperty("u2");
        System.out.println(u1+"/"+u2);
        //创建集合TreeSet
        TreeSet<Customer> customers=new TreeSet<>();
        //集合内存放Customer对象，对象内存入数据
        customers.add(new Customer("zhangsan",25));
        customers.add(new Customer("lisi",23));
        customers.add(new Customer("wangwu",28));
        //遍历
        for (Customer s:customers) {
            System.out.println(s);
        }
        //创建集合的时候传入一个比较器(new一个对象地址)
        //普通类：
        // TreeSet<WuGui> wuGuis = new TreeSet<>(new WuGuiComparator(){
        //内部类：
        TreeSet<WuGui> wuGuis = new TreeSet<>(new Comparator<WuGui>() {
            public int compare(WuGui o1, WuGui o2) {
                return o1.age- o2.age;
            }
        });
        wuGuis.add(new WuGui(800));
        wuGuis.add(new WuGui(200));
        wuGuis.add(new WuGui(600));
        for (WuGui s:wuGuis) {
            System.out.println(s);
        }
        //将ArrayList集合变成线程安全的，对List集合进行排序，需要实现Comparator接口
        List<String>list =new ArrayList<>();
        Collections.synchronizedCollection(list);//将集合list变成线程安全的
        //set类集合转换成List类集合
        Set<String> set =new HashSet<>();
        set.add("fu");
        set.add("gui");
        List<String> listSet =new ArrayList<>(set);//将其转为List类型
        Collections.sort(listSet);//排序
        for (String s:listSet) {
            System.out.println(s);
        }
    }
}
